package com.ysd.lis.service.inv.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.common.Result;
import com.ysd.lis.entity.inv.InvUserManage;
import com.ysd.lis.mapper.inv.InvUserManageMapper;
import com.ysd.lis.service.inv.InvUserManageService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户仓库 服务实现类
 * </p>
 *
 * @author WH
 * @since 2024-09-11
 */
@Service
public class InvUserManageServiceImpl extends ServiceImpl<InvUserManageMapper, InvUserManage> implements InvUserManageService {
    @Autowired
    private InvUserManageMapper invUserManageMapper;

    @Override
    public Result findUserManageList(InvUserManage invUserManage) {
        LambdaQueryWrapper<InvUserManage> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        //参数
        if (!StringUtils.isEmpty(invUserManage.getSearchValue())) {
            lambdaQueryWrapper.and(wrapper ->
                    wrapper.like(InvUserManage::getUserCode, invUserManage.getSearchValue()).or().like(InvUserManage::getUserName, invUserManage.getSearchValue()));
        }
        lambdaQueryWrapper.eq(InvUserManage::getDelFlag, 0);
        lambdaQueryWrapper.eq(InvUserManage::getStoreId, invUserManage.getStoreId());
        lambdaQueryWrapper.orderByAsc(InvUserManage::getSeq);
        List<InvUserManage> invUserManages = invUserManageMapper.selectList(lambdaQueryWrapper);
        return Result.succ(1, "查询成功", invUserManages);
    }
}
